package main

import "fmt"

/**
	多维数组定义
	temArr := [][]int{
		{1,2,8,9},
		{2,4,9,12},
		{4,7,10,13},
		{6,8,11,15},
	}

	循环
	for i:=0; i<len(matrix); i++ {

 */

func lengthOfLongestSubstring(s string) string {
	sLen := len(s)
	if sLen <=0 {
		return ""
	}

	maxLongNum := 0
	maxLongString:= ""

	temMaxLongNum := 0
	var temMaxLongString string = ""

	for i:=0;i<len(s);i++ {
		temMaxLongNum = 0
		temStartStr := string(s[i])
		temMaxLongString = temStartStr

		for j:=i+1;j<len(s);j++ {
			temCheckStr := s[j]

			// 重复终止该层循环
			if isRepeatStr(temStartStr, string(temCheckStr)) {
				break
			}
			temMaxLongNum++
			temMaxLongString += string(temCheckStr)

			if maxLongNum < temMaxLongNum {
				maxLongString = temMaxLongString
			}
		}
	}

	return maxLongString
}

// 检查字符串是否相同
func isRepeatStr(startStr string, checkStr string) bool {
	ret2Return := false
	if len(startStr)==0 || len(checkStr)==0 {
		return ret2Return
	}

	if startStr == checkStr {
		ret2Return = true
	}

	return ret2Return
}


func main()  {
	temString := "abbcdfcf"
	ret:=lengthOfLongestSubstring(temString)
	fmt.Println("check 7 is exist:", ret)
}
